package service

import (
	"blizzard/app/dao"
	"blizzard/app/model"
	"github.com/gogf/gf/util/gconv"
)

var CardType = new(serviceCardType)

type serviceCardType struct {}

func (s *serviceCardType) Add(m *model.CardTypeParam) error {
	var (
		data *model.BxCardType
		err error
	)
	if err = gconv.Struct(m, &data); err != nil {
		return err
	}
	_, err = dao.BxCardType.Save(data)
	if err != nil {
		return err
	}
	return nil
}

func (s *serviceCardType) List() (interface{}, error) {
	all, err := dao.BxCardType.FindAll("id > ?", 0)
	if err != nil {
		return nil, err
	}
	return all, err
}